// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: 1UP Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 16 : TYPE_1UP

// Function declarations
reserve function 1UP_DebugDraw
reserve function 1UP_DebugSpawn

// Static Values

// Tables

function 1UP_DebugDraw
	DrawSprite(stage.playerListPos)
end function


function 1UP_DebugSpawn
	temp5 = 16
	temp4 = 0
	CallFunction(DebugMode_SpawnObject)
	object[arrayPos0].drawOrder = 4
end function


event ObjectMain
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
		if checkResult == 1
			object.type = TypeName[Ring Sparkle]
			if options.gameMode < 2
				player.lives++
				if PleaseReplaceLifeSoundEffect == 1
	PlaySfx(SfxName[LifeDDLC], 0)
else	
	PlaySfx(SfxName[Life], 0)
end if			
				PauseMusic()
				ResetObjectEntity(25, TypeName[Music Event], 2, 0, 0)
				object[25].priority = PRIORITY_ACTIVE
			end if
		end if
	next
end event


event ObjectDraw
	CallFunction(SpecialSetup_Function9)
	DrawSpriteXY(stage.playerListPos, temp0, temp1)
end event


event ObjectStartup
	LoadSpriteSheet("Special/Objects.gif")
	arrayPos0 = 32
	while arrayPos0 < 0x420
		if object[arrayPos0].type == TypeName[1UP]
			object[arrayPos0].drawOrder = 4
		end if
		arrayPos0++
	loop
	SpriteFrame(-12, -12, 24, 24, 251, 176) //Sonic
	SpriteFrame(-12, -12, 24, 24, 351, 276) //Tails
	SpriteFrame(-12, -12, 24, 24, 376, 276) //Knuckles
	SpriteFrame(-12, -12, 24, 24, 251, 176) //Unused
	SpriteFrame(-12, -12, 24, 24, 376, 276) //Unused
	SpriteFrame(-12, -12, 24, 24, 333, 376) //Amy
	SetTableValue(TypeName[1UP], DebugMode_ObjCount, DebugMode_TypeTable)
	SetTableValue(1UP_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
	SetTableValue(1UP_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
	DebugMode_ObjCount++
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Special/Objects.gif")
	SpriteFrame(-12, -12, 24, 24, 251, 176)
end event
